package com.cos66.utils;

import android.app.Service;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;

public class NetWorkUtils {

	ConnectivityManager connectivityManager;
	WifiManager wifiManager;

	public NetWorkUtils(Context context) {
		connectivityManager = (ConnectivityManager) context
				.getSystemService(Service.CONNECTIVITY_SERVICE);
		wifiManager = (WifiManager) context
				.getSystemService(Service.WIFI_SERVICE);
	}

	public boolean isNetOn() {
		return connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED
				|| connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING;
	}

	public boolean isWifiOn() {
		return wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED
				|| wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING;
	}
}
